﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Specialized;

namespace VideoClipNameHelper
{
    public class OptionParser
    {
        public static string GetOptions(string cmdLine, NameValueCollection nv)
        {
            string[] pp = cmdLine.Split(new char[] { '/' });
            if (pp.Length > 1)
            {
                for (int i = 1; i < pp.Length; i++)
                {
                    string[] oo = pp[i].Split(new char[] { ':' }, 2);
                    if (oo.Length < 2)
                    {
                        nv.Add(oo[0].Trim(), "");
                    }
                    else
                    {
                        nv.Add(oo[0].Trim(), oo[1].Trim());
                    }
                }
            }

            return pp[0].Trim();
        }
        public static string[] GetValuesSafe(NameValueCollection nv, string key)
        {
            string[] values = nv.GetValues(key);
            if (null != values)
            {
                return values;
            }
            return new string[] { };
        }

    }//class
}
